package com.wn.study

import androidx.databinding.ObservableField
import androidx.lifecycle.viewModelScope
import androidx.paging.cachedIn
import com.wn.common.base.BaseViewModel
import com.wn.service.db.UserInfo
import com.wn.study.repository.IStudyRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

/**
 * @Author: wn
 * @Date: 2023/6/29 16:39
 * @Description: 学习中心 ViewModel
 */
@HiltViewModel
class StudyViewModel @Inject constructor(private val repository: IStudyRepository) :
  BaseViewModel() {
  // 用户信息
  val obUserInfo = ObservableField<UserInfo>()

  /**
   * 获取 liveData-userinfo的 dao 操作
   */
  fun getLiveUserInfo() = repository.getLiveUserInfo()

  // 获取数据
  fun fetchData() = repository.getDaily().cachedIn(viewModelScope)
}